package com.luych.toolbox.common.feign.view.docker.service;

import com.luych.toolbox.common.enums.DockerContainerStatus;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.util.Date;
import java.util.List;
import java.util.Map;

@ApiModel("容器数据返回")
public class DockerContainerView {

    @ApiModelProperty("名称")
    private String name;
    @ApiModelProperty("容器ID")
    private String id;
    @ApiModelProperty("创建时间")
    private Date created;
    @ApiModelProperty("CPU配置")
    private Long cpu;
    @ApiModelProperty("内存配置")
    private Long mem;
    @ApiModelProperty("内存配置")
    private String memHumanRead;
    @ApiModelProperty("Path")
    private String path;
    @ApiModelProperty("Args")
    private List<String> args;
    @ApiModelProperty("镜像ID")
    private String imageId;
    @ApiModelProperty("镜像名称")
    private String imageName;
    @ApiModelProperty("状态")
    private DockerContainerStatus status;
    @ApiModelProperty("重启策略")
    private String restartPolicy;
    @ApiModelProperty("最大重启次数")
    private Long maxRestartCount;
    @ApiModelProperty("重启次数")
    private Long restartCount;
    @ApiModelProperty("进程PID")
    private Long pid;
    @ApiModelProperty("进程退出码")
    private Long exitCode;
    @ApiModelProperty("是否自动删除")
    private Boolean autoRemove;
    @ApiModelProperty("是否开启特权")
    private Boolean privileged;
    @ApiModelProperty("错误信息")
    private String error;
    @ApiModelProperty("启动时间")
    private Date startedAt;
    @ApiModelProperty("停止时间")
    private Date finishedAt;
    @ApiModelProperty("主机名")
    private String hostname;
    @ApiModelProperty("用户")
    private String user;
    @ApiModelProperty("环境变量")
    private List<String> env;
    @ApiModelProperty("标签")
    private Map<String, String> label;
    @ApiModelProperty("DNS")
    private List<String> dns;
    @ApiModelProperty("HOST配置")
    private List<String> hosts;
    @ApiModelProperty("挂载存储")
    private List<Volume> volumes;
    @ApiModelProperty("挂载网络")
    private List<Network> networks;
    @ApiModelProperty("开放端口")
    private List<Port> ports;
    @ApiModelProperty("监控数据")
    private List<Stat> stats;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Date getCreated() {
        return created;
    }

    public void setCreated(Date created) {
        this.created = created;
    }

    public Long getCpu() {
        return cpu;
    }

    public void setCpu(Long cpu) {
        this.cpu = cpu;
    }

    public Long getMem() {
        return mem;
    }

    public void setMem(Long mem) {
        this.mem = mem;
    }

    public String getMemHumanRead() {
        return memHumanRead;
    }

    public void setMemHumanRead(String memHumanRead) {
        this.memHumanRead = memHumanRead;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public List<String> getArgs() {
        return args;
    }

    public void setArgs(List<String> args) {
        this.args = args;
    }

    public String getImageId() {
        return imageId;
    }

    public void setImageId(String imageId) {
        this.imageId = imageId;
    }

    public String getImageName() {
        return imageName;
    }

    public void setImageName(String imageName) {
        this.imageName = imageName;
    }

    public DockerContainerStatus getStatus() {
        return status;
    }

    public String getStatusValue() {
        return status == null ? null : status.getValue();
    }

    public void setStatus(DockerContainerStatus status) {
        this.status = status;
    }

    public String getRestartPolicy() {
        return restartPolicy;
    }

    public void setRestartPolicy(String restartPolicy) {
        this.restartPolicy = restartPolicy;
    }

    public Long getMaxRestartCount() {
        return maxRestartCount;
    }

    public void setMaxRestartCount(Long maxRestartCount) {
        this.maxRestartCount = maxRestartCount;
    }

    public Long getRestartCount() {
        return restartCount;
    }

    public void setRestartCount(Long restartCount) {
        this.restartCount = restartCount;
    }

    public Long getPid() {
        return pid;
    }

    public void setPid(Long pid) {
        this.pid = pid;
    }

    public Long getExitCode() {
        return exitCode;
    }

    public void setExitCode(Long exitCode) {
        this.exitCode = exitCode;
    }

    public Boolean getAutoRemove() {
        return autoRemove;
    }

    public void setAutoRemove(Boolean autoRemove) {
        this.autoRemove = autoRemove;
    }

    public Boolean getPrivileged() {
        return privileged;
    }

    public void setPrivileged(Boolean privileged) {
        this.privileged = privileged;
    }

    public String getError() {
        return error;
    }

    public void setError(String error) {
        this.error = error;
    }

    public Date getStartedAt() {
        return startedAt;
    }

    public void setStartedAt(Date startedAt) {
        this.startedAt = startedAt;
    }

    public Date getFinishedAt() {
        return finishedAt;
    }

    public void setFinishedAt(Date finishedAt) {
        this.finishedAt = finishedAt;
    }

    public String getHostname() {
        return hostname;
    }

    public void setHostname(String hostname) {
        this.hostname = hostname;
    }

    public String getUser() {
        return user;
    }

    public void setUser(String user) {
        this.user = user;
    }

    public List<String> getEnv() {
        return env;
    }

    public void setEnv(List<String> env) {
        this.env = env;
    }

    public Map<String, String> getLabel() {
        return label;
    }

    public void setLabel(Map<String, String> label) {
        this.label = label;
    }

    public List<String> getDns() {
        return dns;
    }

    public void setDns(List<String> dns) {
        this.dns = dns;
    }

    public List<Volume> getVolumes() {
        return volumes;
    }

    public void setVolumes(List<Volume> volumes) {
        this.volumes = volumes;
    }

    public List<Network> getNetworks() {
        return networks;
    }

    public void setNetworks(List<Network> networks) {
        this.networks = networks;
    }

    public List<Port> getPorts() {
        return ports;
    }

    public void setPorts(List<Port> ports) {
        this.ports = ports;
    }

    public List<String> getHosts() {
        return hosts;
    }

    public void setHosts(List<String> hosts) {
        this.hosts = hosts;
    }

    public Boolean getStartEnable() {
        return DockerContainerStatus.EXITED.equals(this.status) || DockerContainerStatus.CREATED.equals(this.status);
    }

    public Boolean getStopEnable() {
        return DockerContainerStatus.RUNNING.equals(this.status);
    }

    public Boolean getRestartEnable() {
        return DockerContainerStatus.RUNNING.equals(this.status);
    }

    public Boolean getKillEnable() {
        return DockerContainerStatus.RUNNING.equals(this.status);
    }

    public Boolean getPauseEnable() {
        return DockerContainerStatus.RUNNING.equals(this.status);
    }

    public Boolean getResumeEnable() {
        return DockerContainerStatus.PAUSED.equals(this.status);
    }

    public Boolean getRemoveEnable() {
        return DockerContainerStatus.EXITED.equals(this.status) || DockerContainerStatus.CREATED.equals(this.status);
    }

    public List<Stat> getStats() {
        return stats;
    }

    public void setStats(List<Stat> stats) {
        this.stats = stats;
    }

    @ApiModel("容器开放端口")
    public static class Port {

        @ApiModelProperty("宿主机IP")
        private String hostIp;
        @ApiModelProperty("宿主机端口")
        private Long hostPort;
        @ApiModelProperty("容器端口")
        private String containerPort;

        public String getHostIp() {
            return hostIp;
        }

        public void setHostIp(String hostIp) {
            this.hostIp = hostIp;
        }

        public Long getHostPort() {
            return hostPort;
        }

        public void setHostPort(Long hostPort) {
            this.hostPort = hostPort;
        }

        public String getContainerPort() {
            return containerPort;
        }

        public void setContainerPort(String containerPort) {
            this.containerPort = containerPort;
        }
    }

    @ApiModel("容器挂载网络")
    public static class Network {

        @ApiModelProperty("网络ID")
        private String networkId;
        @ApiModelProperty("网络名称")
        private String networkName;
        @ApiModelProperty("IP地址")
        private String ipAddress;
        @ApiModelProperty("MAC地址")
        private String macAddress;
        @ApiModelProperty("网关")
        private String gateway;
        @ApiModelProperty("IP前缀")
        private Long ipPrefixLen;

        public String getNetworkId() {
            return networkId;
        }

        public void setNetworkId(String networkId) {
            this.networkId = networkId;
        }

        public String getNetworkName() {
            return networkName;
        }

        public void setNetworkName(String networkName) {
            this.networkName = networkName;
        }

        public String getIpAddress() {
            return ipAddress;
        }

        public void setIpAddress(String ipAddress) {
            this.ipAddress = ipAddress;
        }

        public String getMacAddress() {
            return macAddress;
        }

        public void setMacAddress(String macAddress) {
            this.macAddress = macAddress;
        }

        public String getGateway() {
            return gateway;
        }

        public void setGateway(String gateway) {
            this.gateway = gateway;
        }

        public Long getIpPrefixLen() {
            return ipPrefixLen;
        }

        public void setIpPrefixLen(Long ipPrefixLen) {
            this.ipPrefixLen = ipPrefixLen;
        }
    }

    @ApiModel("容器挂载存储")
    public static class Volume {

        @ApiModelProperty("源")
        private String source;
        @ApiModelProperty("目标")
        private String destination;
        @ApiModelProperty("模式")
        private String mode;

        public String getSource() {
            return source;
        }

        public void setSource(String source) {
            this.source = source;
        }

        public String getDestination() {
            return destination;
        }

        public void setDestination(String destination) {
            this.destination = destination;
        }

        public String getMode() {
            return mode;
        }

        public void setMode(String mode) {
            this.mode = mode;
        }
    }

    @ApiModel("容器监控数据")
    public static class Stat {

        @ApiModelProperty("CPU使用率")
        private Float cpuUsage;
        @ApiModelProperty("内存使用率")
        private Float memUsage;
        @ApiModelProperty("内存使用情况")
        private String memUsed;
        @ApiModelProperty("内存使用限制")
        private String memTotal;
        @ApiModelProperty("下行带宽")
        private Long netIn;
        @ApiModelProperty("上行带宽")
        private Long netOut;
        @ApiModelProperty("写磁盘")
        private Long blockIn;
        @ApiModelProperty("读磁盘")
        private Long blockOut;

        public Float getCpuUsage() {
            return cpuUsage;
        }

        public void setCpuUsage(Float cpuUsage) {
            this.cpuUsage = cpuUsage;
        }

        public Float getMemUsage() {
            return memUsage;
        }

        public void setMemUsage(Float memUsage) {
            this.memUsage = memUsage;
        }

        public String getMemUsed() {
            return memUsed;
        }

        public void setMemUsed(String memUsed) {
            this.memUsed = memUsed;
        }

        public String getMemTotal() {
            return memTotal;
        }

        public void setMemTotal(String memTotal) {
            this.memTotal = memTotal;
        }

        public Long getNetIn() {
            return netIn;
        }

        public void setNetIn(Long netIn) {
            this.netIn = netIn;
        }

        public Long getNetOut() {
            return netOut;
        }

        public void setNetOut(Long netOut) {
            this.netOut = netOut;
        }

        public Long getBlockIn() {
            return blockIn;
        }

        public void setBlockIn(Long blockIn) {
            this.blockIn = blockIn;
        }

        public Long getBlockOut() {
            return blockOut;
        }

        public void setBlockOut(Long blockOut) {
            this.blockOut = blockOut;
        }
    }
}
